/**
 * 数组索引转换成行列值
 *
 * @param {number} index 索引
 * @param {number} numColumns 一行多少个
 * @returns {row,column} 返回行列
 */
function indexToRowColumn(index, numColumns) {
  if (numColumns <= 0) {
    throw new Error("numColumns must be greater than 0");
  }
  if (index < 0) {
    throw new Error("index must be non-negative");
  }

  const row = Math.floor(index / numColumns);
  const column = index % numColumns;

  return [row, column];
}
